home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-2.iso / Files II / Prog / N-P / NeoAccessIntro 3.0.sit / NeoIncludes / CNeoIterator.h / CNeoIterator.h
Encoding:
C/C++ Source or Header  |  1994-09-17  |  2.7 KB  |  81 lines  |  [TEXT/MMCC]

  1. /************************************************************
  2.  *
  3.  *    Created: Sunday, December 7, 1992 8:56:00 PM
  4.  *    CNeoIterator.h
  5.  *    C++ class definition for index iterator objects
  6.  *
  7.  *
  8.  *    Copyright © Neologic Systems 1992-1994. All Rights Reserved.
  9.  *    All rights reserved
  10.  *
  11.  *
  12.  * Within a class, references to permanent objects are kept
  13.  * in a sorted list called an index. It is often necessary to
  14.  * serial traverse a list of objects in an index. Iterators
  15.  * make the process of traversing an index easier. They also
  16.  * allow indices to be used as all other collection classes.
  17.  *
  18.  ***********************************************************/
  19. #pragma once            /* Include this file only once */
  20. #ifndef __CNeoIterator__
  21. #define __CNeoIterator__ 1
  22.  
  23. #include "NeoTypes.h"
  24. #ifdef CNeoIteratorBaseH
  25. #include CNeoIteratorBaseH
  26. #endif
  27.  
  28. class CNeoPersist;
  29. class CNeoNode;
  30.  
  31. #ifdef CNeoIteratorBase
  32. class CNeoIterator : public CNeoIteratorBase {
  33. #else
  34. class CNeoIterator {
  35. #endif
  36. public:
  37.                         /** Instance Methods **/
  38.                         CNeoIterator(CNeoNode *aNode = nil, CNeoSelect *aKey = nil, const Boolean aForward = TRUE, const Boolean aReset = TRUE);
  39.     virtual                ~CNeoIterator(void);
  40.  
  41.                         /** Access Methods **/
  42.     short                getIndex(void) const {return fIndex;}
  43.     CNeoSelect *        getKey(void) const {return fKey;}
  44.     CNeoNode *            getNode(void) const {return fNode;}
  45.     Boolean                isForward(void) const {return fForward;}
  46.     void                setForward(const Boolean aForward) {fForward = aForward;}
  47.     void                setKey(CNeoSelect *aKey) {fKey = aKey;}
  48.     void                setNode(CNeoNode *aNode, const short aIndex);
  49.  
  50.                         /** Object List Management Methods **/
  51.     virtual Boolean        cross(const Boolean aForward = TRUE);
  52.     virtual CNeoPersist *
  53.                         currentObject(void);
  54.     Boolean                deletingEntry(void);
  55.     virtual void *        doUntil(NeoTestFunc1 aFunc, void *aParam = nil);
  56.     virtual Boolean        leap(const long aDelta);
  57.     virtual Boolean        more(void);
  58.     virtual CNeoPersist *
  59.                         nextObject(void);
  60.     virtual CNeoPersist *
  61.                         previousObject(void);
  62.     virtual CNeoNode *    removeCurrent(void);
  63.     virtual void        reset(void);
  64.  
  65.     Boolean                fForward;                // In which direction do we progress?
  66.     Boolean                fLinear;                // Are we doing a linear search over the index?
  67.     Boolean                fMatched;                // Is the current object a match?
  68.     Boolean                fDone;                    // Have we reached the end of the list?
  69.     short                fIndex;                    // Current entry in the current node.
  70.     CNeoNode *            fNode;                    // The current node.
  71.     CNeoSelect *        fKey;                    // The key that determines which objects to include.
  72.  
  73.     CNeoIterator *        fNextIter;                // Forward reference to iterators looking at fNode
  74.     CNeoIterator *        fPrevIter;                // Backward reference to iterators looking at fNode
  75.  
  76. protected:
  77.     virtual Boolean        advance(const short aDelta);
  78.     void                step(const short aDelta);
  79. };
  80. #endif
  81.